import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Teacher mathTeacher = new Teacher("T001", "张老师");
        Teacher englishTeacher = new Teacher("T002", "李老师");
        Teacher javaTeacher = new Teacher("T003", "王老师");

        Course mathCourse = new Course("C001", "数学", "教学楼101", "周一 8:00");
        Course englishCourse = new Course("C002", "英语", "教学楼102", "周三 10:00");
        Course javaCourse = new Course("C003", "Java编程", "机房201", "周五 14:00");

        Student student = new Student("S001", "小明");

        System.out.println("=== 学生选课系统 ===");

        boolean running = true;
        while (running) {
            System.out.println("\n请选择操作:");
            System.out.println("1. 教师开课");
            System.out.println("2. 学生选课");
            System.out.println("3. 学生退课");
            System.out.println("4. 查看学生课表");
            System.out.println("5. 退出系统");
            System.out.print("请输入选项(1-5): ");

            int choice = scanner.nextInt();

            switch (choice) {
                case 1:
                    System.out.println("\n请选择要开设的课程:");
                    System.out.println("1. 数学");
                    System.out.println("2. 英语");
                    System.out.println("3. Java编程");
                    System.out.print("请输入选项(1-3): ");
                    int courseChoice = scanner.nextInt();

                    if (courseChoice == 1) {
                        mathTeacher.offerCourse(mathCourse);
                    } else if (courseChoice == 2) {
                        englishTeacher.offerCourse(englishCourse);
                    } else if (courseChoice == 3) {
                        javaTeacher.offerCourse(javaCourse);
                    } else {
                        System.out.println("无效选择");
                    }
                    break;

                case 2:
                    System.out.println("\n请选择要选的课程:");
                    System.out.println("1. 数学");
                    System.out.println("2. 英语");
                    System.out.println("3. Java编程");
                    System.out.print("请输入选项(1-3): ");
                    int selectChoice = scanner.nextInt();

                    if (selectChoice == 1) {
                        student.selectCourse(mathCourse);
                    } else if (selectChoice == 2) {
                        student.selectCourse(englishCourse);
                    } else if (selectChoice == 3) {
                        student.selectCourse(javaCourse);
                    } else {
                        System.out.println("无效选择");
                    }
                    break;

                case 3:
                    student.dropCourse();
                    break;

                case 4:
                    student.printSchedule();
                    break;

                case 5:
                    running = false;
                    System.out.println("谢谢使用，再见！");
                    break;

                default:
                    System.out.println("无效选择，请重新输入");
            }
        }

        scanner.close();
    }
}